import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useLoadingStore = defineStore(
  'loadingStore',
  () => {
    const isGlobalLoading = ref(false)
    const loadingText = ref('')

    const openLoading = (text = '') => {
      loadingText.value = text
      isGlobalLoading.value = true
    }
    const closeLoading = () => {
      loadingText.value = ''
      isGlobalLoading.value = false
    }

    return { isGlobalLoading, loadingText, openLoading, closeLoading }
  },
  {
    persist: false //本地持久化存储
  }
)
